1. Field of the Invention
The present invention relates generally to Java™ virtual machines (JVMs), and more particularly, to methods and systems for locking resources that may be shared by multiple applications running in multiple JVMs.
2. Description of the Related Art
Java language programming is an increasing popular software programming language because Java is independent from computing platform (processor and operating system). Java is an interpreted language that uses an intermediate language. The source code of a Java program is compiled to byte code, which cannot be run by itself. The byte code must be converted into machine code at runtime.
A Java virtual machine (JVM) is interprets the byte code to machine code that is compatible with the underlying computing platform. Each type of computing platform requires a specific JVM. Therefore, the byte code of a Java program can be executed on any computing platform that has a JVM that is compatible with the underlying computing platform.
The underlying computer platform, peripheral devices, and the software and data available to underlying computer platform are referred to as resources. A software application being executed on the computing platform can use the resources required to complete the execution of the software application. Often a computer platform will have multiple software applications being executed simultaneously. Often more than one of the multiple software applications may utilize the same resource. For example, two applications may use a single audio channel to output respective audio signals. Therefore, the single audio channel is a shared resource that is shared by the two applications. Use of a shared resource must be arbitrated between the multiple software applications to avoid conflicts and errors.
Similar to an underlying computing platform, each JVM can simultaneously execute multiple applications. Typically, a JVM includes mechanisms to prevent multiple applications from simultaneously accessing a shared resource. By way of example, the JVM includes a JDK. The JDK is a set of objects that the byte code can call to execute the desired operations. Each object in the JDK includes a monitor. The monitor can be claimed or locked by only one application at a time. If a first application locks a first object, by locking the first objects monitor, and then a second application attempts to claim or lock the first object, the first object's monitor will not lock to the second application because the monitor was previously locked to the first application.
Often multiple JVMs may be run at the same time on one computing platform. By way of example, a server may run multiple JVMs to distribute the workload required by the multiple Java programs being executed.
A resource can also be shared among multiple applications that are being executed on multiple JVMs that are on separate (e.g., networked) computing platforms. In one instance and first application is executed on a first JVM on a first computing platform, and a second application is executed on a second JVM on a second computing platform. The first application and the second application can both access a shared resource such as a single database field. The first application can write a first value to the database field. The second application can then write a second value to the database field. Then the first application can read the database field for further processing. However, since the second value was stored in the database field, the second value will be retrieved instead of the intended first value, thereby resulting in errors in the first application.
As described above, the JVMs do not include a system or method to arbitrate the usage of the shared resource (e.g., the database field) that may be shared by multiple applications running in two or more JVMs. As described above, the different JVMs can also be operating on separate, linked computing platforms, which can further complicate the arbitration of the shared resource.
In view of the foregoing, there is a need for a system and method for managing resources that may be shared by multiple applications running in multiple JVMs.